package com.bwie.rabbit;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * TODO
 *
 * @Description
 * @Author 36167
 * @Date 2025/3/10 22:50
 **/


@Component
@Slf4j
public class Rabbit {

    @Autowired
    StringRedisTemplate redisTemplate;

    @RabbitListener(queues = "xty")
    public void a1(Message message){
        String s = new String(message.getBody());
        log.info("接受的消息为:{},时间是:{}",s,new Date());

    }

    @RabbitListener(queues = "day3-12")
    public void a2(Message message){
        String s = new String(message.getBody());
        String[] split = s.split(",");
        String pig=split[0];
        String uid=split[1];
        log.info("商品id为:{},用户id为:{}",pig,uid);
    }

}
